From e6dec7a9ddd0f86f074207bd27dcac526fa97aea Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 5 Sep 2019 10:45:37 +0100 Subject: [PATCH] volume: Ignore slider changes we initiated ourselves Commit 21e14bd46f9774e6c0146cb2169d938e782dba3c fixed this for the brightness slider, but we have the same problem for volume too. When the volume is muted - for example in Settings or via a media key, we update the slider to '0' to indicate this visually. But we also actually invoke the slider's callback to *set* the volume to zero. That means that the previous level is overwritten so it can't be restored when unmuting. The fix is the same - when we update the slider internally ourselves, don't call the signal handler. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1557 --- js/ui/status/volume.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index 470e1f7b4..75ad2cac0 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported Indicator */ -const { Clutter, Gio, Gvc, St } = imports.gi; +const { Clutter, Gio, GObject, Gvc, St } = imports.gi; const Signals = imports.signals; const Main = imports.ui.main; @@ -36,7 +36,8 @@ var StreamSlider = class { this._soundSettings.connect(`changed::${ALLOW_AMPLIFIED_VOLUME_KEY}`, this._amplifySettingsChanged.bind(this)); this._amplifySettingsChanged(); - this._slider.connect('notify::value', this._sliderChanged.bind(this)); + this._sliderChangedId = this._slider.connect('notify::value', + this._sliderChanged.bind(this)); this._slider.connect('drag-end', this._notifyVolumeChange.bind(this)); this._icon = new St.Icon({ style_class: 'popup-menu-icon' }); @@ -129,10 +130,16 @@ var StreamSlider = class { this._volumeCancellable); } + _changeSlider(value) { + GObject.signal_handler_block(this._slider, this._sliderChangedId); + this._slider.value = value; + GObject.signal_handler_unblock(this._slider, this._sliderChangedId); + } + _updateVolume() { let muted = this._stream.is_muted; - this._slider.value = muted - ? 0 : (this._stream.volume / this._control.get_vol_max_norm()); + this._changeSlider(muted + ? 0 : (this._stream.volume / this._control.get_vol_max_norm())); this.emit('stream-updated'); } -- 2.39.5